package Action;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import Dao.userdao;
import Entity.User;
import mapper.Usermapper;

/**
 * Servlet implementation class ChangeServlet
 */
@WebServlet("/ChangeServlet")
public class ChangeServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ChangeServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#service(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
        String new_pwd=request.getParameter("new_pwd");
        HttpSession session = request.getSession();
        User user =(User) session.getAttribute("user");
        String Uid = user.getUid();
        User u= new User();
        u.setUid(Uid);
        u.setPwd(new_pwd);
        System.out.println("用户"+Uid+"新密码 "+new_pwd);
        Usermapper um = new userdao();
        um.Change_Pwd(u);
        request.getRequestDispatcher("personInfor.jsp").forward(request,response);
	}

}
